-
-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP [16.0] add account_ecotax module #428
base: 16.0
Are you sure you want to change the base?
Conversation
4b800eb
to
4875e19
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM: some nitpicking + code review (not an expert in France taxes)
'1: check "included in base amount "\n' | ||
"2: The Ecotax sequence must be less then " | ||
"VAT tax (in sale and purchase)", | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we may rename is_ecotax to ecotax as fields Selection (('fixed', 'Fixed'), ('weight', 'Weight')] because it can lead to misconfiguration.
Domain can prevent this error.
cc @mourad-ehm @yankinmax ?
Also there case where ecotax should be considered as surface or volume, not implemented there but could be with additional entry in field Selection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is_ecotax
and ecotax_type
are different fields, so no misconfiguration here.
Taxes are filtered by is_ecotax
in computations.
I don't see issue here actually. But, I can miss something of course
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're they are different fields but they might the same with a selection field in a mixin class.
Here ecotax computing fails because product _compute_product_ecotax
method search for a fixed ecotax amount and sale order apply 'ecotaxe poids' , then ecotax is 0 on sale order line because there is only fixed ecotax amount not computed
here is code for weight tax case,
and commented line for fixed case is below
Ecotax classification data for this test: | ||
- fixed type | ||
- default amount: 5.0 | ||
Product data for this test: | ||
- list price: 100 | ||
- fixed ecotax | ||
- no manual amount | ||
|
||
Expected results (with 1 line and qty = 1): | ||
- invoice ecotax amount: 5.0 | ||
- invoice total amount: 100.0 | ||
- line ecotax unit amount: 5.0 | ||
- line ecotax total amount: 5.0 | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why invoice total amount 100
and not 120
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me you're right. @mourad-ehm will have a look tomorrow
BTW: I'm on migration of
And the most important |
some fix there akretion#7 |
@mourad-ehm @bealdav Thanks |
Possible dumb question. Thanks! |
Certainly dumb question: what are "OOB Taxes"? |
) | ||
def _compute_ecotax(self): | ||
for ecotaxline in self: | ||
ecotax_cls = ecotaxline.classification_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend not abbreviating to "cls" : this makes developpers think of a Python class. When I see a variable called ecotax_cls
, I think it refers to a Python class for Ecotax, not to a ecotax.classification record.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm globally worried by the move to account.tax to manage these. All my manual tests showed wrong results, at least from a FR fiscal perspective: wrong amount untaxed for the product (the "ecotax" should not be removed, only the VAT).
If I sell a product 100€ (HT) with 20% VAT and 1.12 écocontribution included to my customer. the amount untaxed on the invoice must be 100€, not 98.88€. There must be a label saying that in these 100€, there is 1.12€ of ecocontribution. And in my VAT report, the base amount that shows up must be 100€.
"company_id": cls.env.user.company_id.id, | ||
} | ||
) | ||
# 2- Invoice tax with included price to avoid unwanted amounts in tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a set of tests with taxes not included in price. The default tax in France in Odoo is a 20% G which is not included in price, switching this is not an option for FR users.
self._run_checks( | ||
invoice, | ||
{"amount_ecotax": 5.0 * new_qty, "amount_total": 100.0 * new_qty}, | ||
[{"ecotax_amount_unit": 5.0, "subtotal_ecotax": 5.0 * new_qty}], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had failures on this when running the test manually through the UI: the subtotal_ecotax was staying the same.
def onchange_is_ecotax(self): | ||
if self.is_ecotax: | ||
self.amount_type = "code" | ||
self.include_base_amount = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to set include_base_amount
too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. It is a odoo method to compute imbricated taxes
ecotax_ids = line.tax_ids.filtered(lambda tax: tax.is_ecotax) | ||
|
||
if line.display_type == "tax" or not ecotax_ids: | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set computed values to 0
?
) | ||
ecotax_amount_unit = fields.Float( | ||
digits="Ecotax", | ||
string="Ecotax Unit", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This name is confusing. Is it a unit price?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
if line.display_type == "product" and line.move_id.is_invoice(True): | ||
amount_currency = line.price_unit * (1 - line.discount / 100) | ||
handle_price_include = True | ||
quantity = line.quantity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing: handling of the UoM on the line
"Out Of the Box" 😺 |
(Edited following further tests) Ecotax (in France) is not a real "tax".
I am curious :) |
Don't forget that you can set your tax as include OR NOT in the Price with native odoo settings. |
@bealdav @gurneyalex After further testing,
I am supposed to get Ecotax = 30€ and Ecotax unit = 10€.
|
@mourad-ehm are you still working on this? |
@gurneyalex Mourad is on holidays. You can join me tomorrow with my mail/phone. Thanks |
2c6b35d
to
7adccf2
Compare
@bealdav @mourad-ehm @alexis-via @gurneyalex @epanisset In this commit 7adccf2 I made a few fixes in the tests where recent field renames were not properly applied I left the commit as e separate commit so you can easily see what I did, but before merging it will have to be squashed into the "Apply suggestions from code review " commit. BTW, see the OCA guidelines for the commit messages here: Despite my fixes there are still failing tests with wrong tax values... |
Please check formulae in python tax computed, adjust it. |
cc @mourad-ehm please could you plan to make final commits next week please. It becomes necessary now. Thanks |
account_ecotax/models/account_tax.py
Outdated
# result = product.weight_based_ecotax or 0.0 | ||
result = product.fixed_ecotax or 0.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# result = product.weight_based_ecotax or 0.0 | |
result = product.fixed_ecotax or 0.0 | |
if product.weight_based_ecotax: | |
result = product.weight_based_ecotax or 0.0 | |
else: | |
result = product.fixed_ecotax or 0.0 |
for tax in compute_all_currency["taxes"]: | ||
subtotal_ecotax += tax["amount"] | ||
|
||
unit = subtotal_ecotax / quantity if quantity else subtotal_ecotax |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unit = subtotal_ecotax / quantity if quantity else subtotal_ecotax | |
unit = subtotal_ecotax * quantity if quantity else subtotal_ecotax |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unit represent the ecotax amount for 1 product (for reporting purpose). The multiplication by the quantity is set in python code of taxes (see the readMe file).
/rebase |
Co-authored-by: Maksym Yankin <[email protected]>
Co-authored-by: Alexandre Fayolle <[email protected]>
Co-authored-by: Alexandre Fayolle <[email protected]>
7adccf2
to
fc67913
Compare
Hi @gurneyalex I improved RedMe file to show how to configure ecotaxes and so fix the qty issue. |
40068e1
to
ff0cdc3
Compare
No description provided.